<!--  Copyright 2020 Zhejiang Lab and Zhejiang University. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================
-->

<template>
  <b-container>
    <b-col>
      <b-nav tabs>
        <b-nav-item active-class="active" :to="{name: 'Upload Model'}">上传模型</b-nav-item>
        <b-nav-item active-class="active" :to="{name: 'My Models'}">我的模型</b-nav-item>
        <b-nav-item active-class="active" :to="{name: 'Public Models'}">公开模型</b-nav-item>
      </b-nav>
      <div class="pt-4">
        <router-view></router-view>
        <b-modal
          title="模型"
          no-close-on-esc
          ok-only
          :visible="is_dialog_open"
          ok-title="确定"
          @close="closeDialog"
          @ok="closeDialog"
          :title-class="{style: {fontSize:'50px'}}"
        >
          <div class="text-center" :style="style.modal" >{{dialog_content}}</div>
        </b-modal>
      </div>
    </b-col>
  </b-container>
</template>

<script>
import { mapState, mapActions, mapMutations } from "vuex";
import { closeDialog } from "../store/utils";

export default {
  name: "Model",
  data: function() {
    return {
      style: {
        modal: {
          wordBreak: "break-all"
        }
      }
    };
  },
  computed: mapState("model", {
    errors: state => state.errors,
    is_dialog_open: state => state.is_dialog_open,
    dialog_content: state => state.dialog_content
  }),
  methods: {
    ...mapMutations("model", [
      "setErrors",
      "setIsDialogOpen",
      "setDialogContent"
    ]),
    closeDialog
  },
};
</script>